<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>改单修改收货地址</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{style/admin.css}" media="all">
    <!--<link rel="stylesheet" th:href="@{/style/admin.css}" media="all">-->
    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.config.js}"></script>
    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.all.min.js}"> </script>
    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script>
    <script type="text/javascript" th:src="@{/laydate/laydate.js}"></script>
    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header"  th:content="${_csrf.headerName}"/>
    <style type="text/css">
        .product-price{
            width:50px;
            border: none;
        }
        #editor{
            margin-left: 120px;
        }
        .one-img{
            border: 1px solid red;
            height: 100px;
            width: 100px;
            margin-left: 110px;
        }
        .Fengetext{
            color: red;
        }
        .layui-card-header .layui-icon {
            line-height: initial;
            position: absolute;
             right: 0px;
            top: 50%;
            margin-top: -15px;
        }
        .upaction{
            background: red;
        }

        .addproduct{
            /*background: #3c3c3c;*/

        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">

                <div class="layui-form-item">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" th:value="${address.name}" id="name" name="name" autocomplete="off" placeholder="请输入姓名" value="0" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-block">
                        <input type="text" id="phone" th:value="${address.phone}"  name="phone" autocomplete="off"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">地址</label>
                    <div class="layui-input-block">
                        <input type="text" data="0" id="address" disabled="disabled" th:value="${address.provinceName+address.cityName+address.areaName}" name="address" autocomplete="off" placeholder="请输入地址" value="" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <form name="form" class="form">
                        <label class="layui-form-label">物流类型</label>
                        <div class="layui-input-block">
                            <div class="layui-input-inline">
                                <select name="quiz1" id="logtype"  lay-verify="required"   lay-filter="selectlogtype">
                                    <option th:if="${address.logisticsType==2}" selected="selected" value="2">快递</option>
                                    <option th:unless="${address.logisticsType!=2}" value="1">自提</option>
                                    <option th:if="${address.logisticsType==1}" selected="selected"  value="1">自提</option>
                                    <option th:unless="${address.logisticsType!=1}"    value="2">快递</option>
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-form-item">
                    <form name="form" class="form">
                        <label class="layui-form-label">选择地址</label>
                        <div class="layui-input-block">
                            <div class="layui-input-inline">
                                <select name="quiz1" id="yj"  lay-verify="required"   lay-filter="selectyj">
                                    <option value="0">请选择省份</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="quiz2" id="rj" lay-filter="selectrj">
                                </select>
                            </div>
                            <div class="layui-input-inline" >
                                <select name="quiz3" id="sj" lay-filter="selectsj">
                                </select>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">详细地址</label>
                    <div class="layui-input-block">
                        <input type="text" id="detailAddress" th:value="${address.detailAddr}" name="detailAddress" autocomplete="off" placeholder="请输入详细地址"  class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" id="remark" th:value="${address.detailAddr}" name="remark" autocomplete="off" placeholder="请输入备注"  class="layui-input">
                    </div>
                </div>


            </div>
        </div>


        </div>
            </div>
<input type="hidden" id="sure" th:data="${address.id}">
        <!--<div class="layui-form-item">-->
            <!--<div class="layui-input-block">-->
                <!--<button class="layui-btn addproduct" id="sure" th:data="${address.id}" lay-submit="" lay-filter="demo1" onclick="saveArea(this)">确认</button>-->
                <!--&lt;!&ndash;<button type="reset" class="layui-btn layui-btn-primary">重置</button>&ndash;&gt;-->
            <!--</div>-->
        <!--</div>-->
    </div>
</div>

<script th:src="@{layui/jquery.min.js}"></script>
<script th:src="@{layui/layui.js}"></script>
<!--<script th:src="@{js/productList.js}"></script>-->
<script>
    var header = $("meta[name='_csrf_header']").attr("content");
    var token =$("meta[name='_csrf']").attr("content");

    var sjId;
    var provinceName="",cityName="",areaName="";
    var provinceId=0,cityId=0,areaId=0;
    $(document).ready(function(){
        layui.use('form', function(){
            var form = layui.form;
            form.on('select(selectyj)', function(data){
                var yjId=data.value;
                loadrj(yjId)//调用二级
                provinceName=data.elem[data.elem.selectedIndex].text;
                provinceId=yjId+",";
                $("#address").attr('data',provinceId);
            });
            form.render();

            form.on('select(selectrj)', function(data){
                var rjId=data.value;
                loadsj(rjId);
                cityName=data.elem[data.elem.selectedIndex].text;
                cityId=rjId+",";
                $("#address").attr('data',cityId);
            });
            form.render();

            form.on('select(selectsj)', function(data){
                sjId=data.value;
                areaName=data.elem[data.elem.selectedIndex].text;
                areaId=sjId;
               // $("#address").val(provinceName+cityName+areaName);
                $("#address").val(provinceName+cityName+areaName);
                $("#address").attr('data',provinceId+cityId+areaId)
            });
            form.render();
        });
        var date=new Date();
        var year=date.getFullYear();
        var productNo=Math.random().toString().substring(2);
        var str=year.toString()+productNo;
        $("#productNo").attr("value",str);
    });


    //执行一个laydate实例
    var data;
    laydate.render({
        elem: '#upTime',//指定元素
        format: 'yyyy-MM-dd HH:mm:ss'
        ,value: '2017-09-10 10:10:10'
        ,done: function (value,date) {
            console.log(date);
            if(date!=null||date!=""){
                data=date;
            }else{
                alert("请选择商品上传时间！");
            }

        }
    });

    //复选框
    var productUp;
    layui.use('form',function () {
        var checkboxform = layui.form;
        checkboxform.on('checkbox(checkbox)',function (data) {
            console.log(data.elem.checked);
            productUp=data.elem.checked;
        })
    })
     var productNo="";
    var productId=0;
</script>

<script>
   $(document).ready(function () {
       loadProvince();

   })

    function loadProvince() {
        var str = "";
        $.ajax({
            url:"/selectAreaList?parentId=0&level=0",
            dataType: 'json',
            contentType: 'application/json',
            async: false,
            success: function (result) {
                var data=result;
//var datahref=$(data.elem).find("option:selected").attr("data-href");
                for(var index in data){
                    //str = str + "<option value='" +data[index].classId+ "'>" + data[index].classifyName+ "</option>";
                     $("#yj").append("<option value='" +data[index].id+"'>" + data[index].name+ "</option>");
                }
                //$("#yj").html(str);
            }
        });
    }

    function loadrj(id) {
            var  str="";
            $.ajax({
                url:"/selectAreaList?level=1&parentId="+id,
                success:function (result) {
                    var data=result;
                    $('#rj').empty();
                    for(var index in data){
                        $("#rj").append("<option value='" +data[index].id+ "'>" + data[index].name+ "</option>");
                        layui.use('form', function() {
                            var form = layui.form;
                            form.render();
                        })
                    }
                }
            })
    }

   function loadsj(id) {
       var  str="";
       $.ajax({
           url:"/selectAreaList?level=2&parentId="+id,
           success:function (result) {
               var data=result;
               $('#sj').empty();
               for(var index in data){
                   $("#sj").append("<option value='" +data[index].id+ "'>" + data[index].name+ "</option>");
                   layui.use('form', function() {
                       var form = layui.form;
                       form.render();
                   })
               }
           }
       })
   }
</script>

</body>
</html>

